package Chap06;
import java.util.Objects;

public class Student {
    private String sNo;
    private String sName;
    private String sSex;
    private int  sAge;
    private double sJava;
    //构造无参函数
    public Student() {
    }
    //构造有参函数
    public Student(String sNo, String sName, String sSex, int sAge, double sJava) {
        this.sNo = sNo;
        this.sName = sName;
        this.sSex = sSex;
        this.sAge = sAge;
        this.sJava = sJava;
    }
    //封装
    public String getsNo() {
        return sNo;
    }

    public void setsNo(String sNo) {
        this.sNo = sNo;
    }

    public String getSName() {
        return sName;
    }

    public void setSname(String sName) {
        this.sName = sName;
    }

    public String getsSex() {
        return sSex;
    }

    public void setsSex(String sSex) {
        this.sSex = sSex;
    }

    public int getsAge() {
        return sAge;
    }

    public void setsAge(int sAge) {
        this.sAge = sAge;
    }

    public double getsJava() {
        return sJava;
    }

    public void setsJava(double sJava) {
        this.sJava = sJava;
    }
    //重写equal和hashCode
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return sAge == student.sAge &&
                Double.compare(student.sJava, sJava) == 0 &&
                Objects.equals(sNo, student.sNo) &&
                Objects.equals(sName, student.sName) &&
                Objects.equals(sSex, student.sSex);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sNo, sName, sSex, sAge, sJava);
    }
    //重写toString
    @Override
    public String toString() {
        return "学号:" + sNo  +
                "\t姓名:" + sName  +
                "\t性别:" + sSex  +
                "\t年龄:" + sAge +
                "\tJava成绩:" + sJava ;

    }
}
